

from tkinter import *


root = Tk()


sb = Scrollbar(root)

sb.pack(side=RIGHT,fill=Y)


city = Listbox(root,
        selectmode=MULTIPLE,
        yscrollcommand=sb.set
        );


city.pack(side=LEFT,fill=BOTH)

# yview listbox 的默认犯法，设置好怎么显示垂直滚动对应的 内容变化
sb.config(command=city.yview)
  
cityList=[
    "北海",
    "北京",
    "深圳",
    "杭州",
    "苏州",
    "南京",
    "云南",
    "南宁",
    "钦州",
    "柳州",
    "桂林",
    "西宁",
    "广州",
    "哈尔滨",
    "齐齐哈尔",
]


# 添加滚动组件


for i in cityList:
    city.insert(END,i)

btn = Button(root,text="删除他",
command = lambda x = city:x.delete(ACTIVE))

btn.pack()

mainloop()